﻿@{
    ViewBag.Title = "Index2";
    //if (IsAjax)
    //{
    //    Layout = null;
    //}
}

<div id="cphMain_ctl00_ContentPane" class="center">
<link rel="stylesheet" href="/Content/static.bizwebmedia.net/Extensions/Stylesheet/Gallery/nivo-slider.css" type="text/css" media="screen" />
<script src="/Content/static.bizwebmedia.net/Extensions/Js/GalleryModule/jquery.nivo.slider.js" type="text/javascript"></script>
<style type="text/css">
#slider{ background: #202834 url(/Content/static.bizwebmedia.net/images/loading2.gif) no-repeat 50% 50%; height: 240px; margin-bottom: 10px; overflow: hidden; position: relative; width: 589px; }
#slider img{ display: none; left: 0px; position: absolute; top: 0px; }
#slider a{ border: 0; }
.nivo-controlNav{ bottom: -30px; left: 47%; position: absolute; }
.nivo-controlNav a{ background: url(/Content/static.bizwebmedia.net/images/bullets.png) no-repeat; border: 0; display: block; float: left; height: 10px; margin-right: 3px; text-indent: -9999px; width: 10px; }
.nivo-controlNav a.active{ background-position: -10px 0; }
.nivo-directionNav a{ background: url(/Content/static.bizwebmedia.net/images/arrows.png) no-repeat; border: 0; display: block; height: 34px; text-indent: -9999px; width: 32px; }
a.nivo-nextNav{ background-position: -32px 0; right: 10px; }
a.nivo-prevNav{ left: 10px; }
#slider p{ font-family: Arial, sans-serif; margin-left: 10px; }
#slider p span{ font-family: Helvetica; font-size: 10px; }
.nivo-caption{ height: 40px; }
.nivo-caption { display: none !important; }
.nivo-caption p{ font-family: Arial; font-size: 14px; padding-top: 10px; }
</style>
@*<script type="text/javascript">
    $j(window).load(function () {
        $j('#slider').nivoSlider({
            effect: 'random', //Specify sets like: 'fold,fade,sliceDown' fade
            slices: 15,
            width: 589,
            height: 240,
            animSpeed: 500,
            pauseTime: 5000,
            startSlide: 0, //Set starting Slide (0 index)
            directionNav: true, //Next & Prev
            directionNavHide: true, //Only show on hover
            controlNav: true, //1,2,3...
            controlNavThumbs: false, //Use thumbnails for Control Nav
            controlNavThumbsFromRel: false, //Use image rel for thumbs
            controlNavThumbsSearch: '.jpg', //Replace this with...
            controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
            keyboardNav: true, //Use left & right arrows
            pauseOnHover: true, //Stop animation while hovering
            manualAdvance: false, //Force manual transitions
            captionOpacity: 0.0, //Universal caption opacity
            beforeChange: function () { },
            afterChange: function () { },
            slideshowEnd: function () { } //Triggers after all slides have been shown
        });
    });
</script>*@
<div id="slider" style="margin: 0 auto;">
    
            @Html.Action("SliderShow", "Main");                 
        
</div>
    <script type="text/javascript">
        loadSlider();
    </script>

<div id="HomeFeaturedProducts" class="Block FeaturedProducts DefaultModule">
    <div class="defaultTitle TitleContent">
        <span>Sản phẩm mới nhất tháng 10</span>
    </div>
    <div class="defaultContent BlockContent">     
     @{int count = Enumerable.Count(ViewBag.list);
        string first = "First";     
     for(int i=0; i < ((count-1)/4 + 1); i ++)
     {         
         if(i>0)
         {
             first = "";           
         }
                    <ul class="ProductList @first">                    
                        @{ string old_even;
                    for(int j=i*4; j<(i+1)*4 && j<count; j++)
                    {
                        var pro = Enumerable.ElementAt(ViewBag.list, j);                        
                        if(j%2==0)
                        {    
                            old_even = "Odd";
                        }else{
                            old_even = "Even";
                        }
                        <li class="@old_even">
                                <div id="ProductImage" class="ProductImage ProductImageTooltip po_190309">
                                    <a  href="javascript:;" onclick="javascript:viewProduct(@pro.ID)"  rel="2172035" class="#tooltip2172035"
                                        productname='@pro.name' quantity='@pro.amount @pro.type / thùng' 
                                        thumbnail='/Content/data/images/350.300/@pro.image_link' 
                                        thumbnailerror='/Content/data/images/not_available.jpg' volume='@pro.volume' >
                                        <img alt="@pro.name" title="@pro.name" 
                                                src="/Content/data/images/350.300/@pro.image_link" height="120"
                                            onerror="/Content/data/images/not_available.jpg" />
                                    </a>
                                </div>
                            @if (pro.promotion_ID > 0)
                            {
                                <div class="saleFlag iconSprite ">
                                    @pro.Promotion.rate<span>%</span></div>
                            }                                
                                <div class="ProductDetails">
                                    <strong><a href="javascript:;" onclick="javascript:viewProduct(@pro.ID)">
                                        @pro.name<span class='Flag-Promotion'>&nbsp;</span></a></strong>
                                </div>
                                <div class="ProductPrice">
                                    @{ string retail_price = pro.price.ToString("0,0") + "VND / thùng";
                                       decimal sale_price = pro.price;
                                       if (pro.promotion_ID > 0)
                                       {
                                           sale_price = pro.price / 100 * (100 - pro.Promotion.rate);                                           
                                       }
                                       else
                                       {
                                           retail_price = "";
                                       }
                                    <!--<div class="retail-price disable">                                        
                                        <span class="price-label"></span><span class="price"><strike class="RetailPriceValue">                                            
                                             @Convert.ToInt32(pro.price) ₫</strike>
                                        </span>                                        
                                    </div>-->
                                        <div class="retail-price ">                                        
                                        <span class="price-label"></span><span class="price">
                                            &nbsp;<strike class="RetailPriceValue">                                            
                                            @retail_price
                                            </strike>
                                        </span>                                        
                                    </div>
                                    <div class="special-price">
                                        <span class="price-label"></span><span class="price"><em>
                                            @sale_price.ToString("0,0") VND / thùng</em>
                                        </span>
                                    </div>
                                    }
                                </div>
                             <!--   <div class="ProductRating Rating-1" style="display: ;">
                                    <div class="RatingImage">
                                    </div>
                                </div> -->
                                <div class="ProductActionAdd">
                                    <a href="javascript:;" onclick="javascript:addWishlist(@pro.ID,'@Session["username"]')"><span>Thích</span></a>
                                    <a href="javascript:;" onclick="javascript:addProToCart(@pro.ID,1)"><span>Mua hàng</span></a>
                                </div>
                            </li>                                               
                    }
                    <br class="Clear" />
                        }
                </ul>         
                
     }  
     }    
        
        <div class="PageNavigation" style="padding-bottom: 10px; padding-top: 10px;" align="center">
            @{var previousPage = Math.Max(ViewBag.currentPage-1, 1);}
            <a  href="javascript:;" onclick="javascript:loadActionData('Index2','Main','pageNum=@previousPage')">&lt;&lt;</a>    
            @for(int num = 1; num <= ViewBag.maxPage; num ++)
            {
               if(ViewBag.currentPage == num)
               {
                  <a class="active" href="#" 
                      style="background-color:gray;color:white;"><strong>@num</strong></a>
                }
                else
                {
                   <a  href="javascript:;" onclick="javascript:loadActionData('Index2','Main','pageNum=@num')">@num</a>    
                }
            }                   
            @{var nextPage = Math.Min(ViewBag.maxPage, ViewBag.currentPage + 1);}
            <a href="javascript:;" onclick="javascript:loadActionData('Index2','Main','pageNum=@nextPage')">&gt;&gt;</a>    
        </div>
        <div class="Clear"></div>
              
    </div>
    <div class="defaultFooter FooterContent">
        <div></div>
    </div>
    <div class="Clear"></div>
</div>

<div id="productReviewPopup190309" class="hidden"></div>
<script type="text/javascript">
    $j(function () {
        $j(".ProductList .po_190309 a").each(function () {
            var productname = $j(this).attr("productname");
            var thumbnail = $j(this).attr("thumbnail");
            var thumbnailerror = $j(this).attr("thumbnailerror");
            var quantity = $j(this).attr("quantity");
            var volume = $j(this).attr("volume");
            $j(this).bind("mouseover", function () {
                
                var returnHtml =
                    "<div class=\"tooltip_name\">" + productname + '</div>' +
                    "<div class=\"tooltip_picture\">" +
                        "<img src=\"" + thumbnail + "\" onerror=\"this.src='" + thumbnailerror + "'\" title=\"" + productname
                        + "\" alt=\"" + productname + "\" height=\"250\"/></div>" +
                    "<div class=\"tooltip_description\">Số lượng: " + quantity + "</div>" +
                    "<div class=\"tooltip_description\">Thể tích: " + volume + " ml</div>"
                $j("#productReviewPopup190309").html(returnHtml);
            });
            $j(this).tooltip({
                track: true, delay: 50, showURL: false,
                bodyHandler: function () {
                    return $j("#productReviewPopup190309").html();
                }
            });
        });
    });
</script>

</div>
